package com.situ.student.ui;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.situ.student.util.SwingUtil;

public class AddShareFrame extends JFrame {
	JTextField nameText = new JTextField();
	JTextField ageText = new JTextField();
	JTextField genderText = new JTextField();
	JButton saveButton = new JButton("保存");

	public void init() {
		this.setSize(300, 350);
		this.setLocation(300, 50);
		SwingUtil.setLocationCenter(this);
		// 只是销毁这个
		this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

		JPanel mainPanel = (JPanel) this.getContentPane();
		BoxLayout boxLayout = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
		mainPanel.setLayout(boxLayout);
		// 姓名
		JPanel namePanel = new JPanel();
		JLabel nameLable = new JLabel("姓名： ");
		namePanel.add(nameLable);
		nameText.setPreferredSize(new Dimension(120, 30));
		namePanel.add(nameText);
		// 年龄
		JPanel agePanel = new JPanel();
		JLabel ageLable = new JLabel("年龄： ");
		agePanel.add(ageLable);
		ageText.setPreferredSize(new Dimension(120, 30));
		agePanel.add(ageText);
		// 性别
		JPanel genderPanel = new JPanel();
		JLabel genderLable = new JLabel("性别： ");
		genderPanel.add(genderLable);
		genderText.setPreferredSize(new Dimension(120, 30));
		genderPanel.add(genderText);
		// 保存按钮
		JPanel savePanel = new JPanel();
		saveButton.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub

			}
		});
		savePanel.add(saveButton);
		// 添加Panel
		mainPanel.add(namePanel);
		mainPanel.add(agePanel);
		mainPanel.add(genderPanel);
		mainPanel.add(savePanel);
		this.setVisible(true);
	}
}
